home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _73B9A6524B2247E0921CC5CD8257EA85 < prev    next >
Encoding:
Text File  |  2004-01-06  |  3.8 KB  |  175 lines

  1. DamageArea = {
  2.     type = "DamageArea",
  3.     Properties = {    
  4.         damageRate = 5,
  5.         bEnabled = 1,
  6.         },
  7.     Editor={
  8.         Model="Objects/Editor/T.cgf",
  9.     },
  10.  
  11.     curDamageRate = 0,    
  12.     curDamage = 0,
  13.     isEnabled = 1,
  14.     
  15.     hit = {
  16.         dir = {x=0, y=0, z=1},
  17.         damage = 0,
  18.         target = nil,
  19.         shooter = nil,
  20.         landed = 1,
  21.         impact_force_mul_final=5,
  22.         impact_force_mul=5,
  23.         damage_type = "normal",
  24.         };
  25.     
  26.     
  27. }
  28.  
  29.  
  30.  
  31.  
  32. function DamageArea:CliSrv_OnInit()
  33.  
  34.     self:RegisterState("Inactive");
  35.     self:RegisterState("Active");
  36.     self:GotoState("Inactive");
  37.  
  38. end
  39.  
  40. -----------------------------------------------------------------------------
  41. function DamageArea:OnReset( player,areaId,fadeCoeff )
  42.  
  43.     self:GotoState("Inactive");
  44.     self.isEnabled = self.Properties.bEnabled;
  45.     
  46. end
  47.  
  48.  
  49. -----------------------------------------------------------------------------
  50. --    fade: 0-out 1-in
  51. function DamageArea:OnProceedFadeAreaClient( player,areaId,fadeCoeff )
  52.  
  53.     self.curDamageRate = self.Properties.damageRate*fadeCoeff;
  54.  
  55. --System:LogToConsole("--> bfly FadeIS "..fadeCoeff );
  56. --    System.SetViewDistance(1200);
  57. end
  58.  
  59. -----------------------------------------------------------------------------
  60. function DamageArea:OnEnterAreaClient( player,areaId )
  61.  
  62. System:LogToConsole("--> Entering DamageArea Area "..areaId);
  63.     self:GotoState("Active");
  64. end
  65.  
  66. -----------------------------------------------------------------------------
  67. function DamageArea:OnLeaveAreaClient( player,areaId )
  68.  
  69. System:LogToConsole("--> Leaving DamageArea Area "..areaId);
  70.  
  71. --    if(player ~= _localplayer) then
  72. --        return
  73. --    end    
  74.     
  75.     self:GotoState("Inactive");
  76.  
  77. end
  78.  
  79. -----------------------------------------------------------------------------
  80. function DamageArea:OnUpdateActiveClient( dt )
  81.  
  82. --System:Log("\001 dRate ".._localplayer.cnt.health.." "..self.curDamage);
  83.  
  84.     if(self.isEnabled == 0) then return end
  85.  
  86.     self.curDamage = self.curDamage + self.curDamageRate*dt;
  87.     
  88.     if( self.curDamage > 1 ) then
  89. --        _localplayer.cnt.health    = _localplayer.cnt.health - 1;
  90. --        _localplayer.cnt.health    = _localplayer.cnt.health - self.curDamage;
  91. --        self.curDamage = 0;
  92. --        if(_localplayer.cnt.health < 0) then
  93. --            _localplayer.cnt.health = 0;
  94. --        end    
  95.         self.hit.damage = self.curDamage;
  96.         self.hit.target = _localplayer;
  97.         self.hit.shooter = _localplayer;
  98.         self.hit.dir = {x=0, y=0, z=1};
  99.         self.hit.landed = 1;
  100.         self.hit.impact_force_mul_final=0;
  101.         self.hit.impact_force_mul=0;
  102.         self.hit.damage_type = "normal";
  103.  
  104.         _localplayer:Damage( self.hit );
  105.         self.curDamage = 0;
  106.     end    
  107.  
  108. end
  109.  
  110.  
  111. -----------------------------------------------------------------------------
  112. function DamageArea:OnShutDown()
  113. end
  114.  
  115.  
  116. DamageArea.Server={
  117.     OnInit=function(self)
  118.         self:CliSrv_OnInit()
  119.     end,
  120.     OnShutDown=function(self)
  121.     end,
  122.     Inactive={
  123.     },
  124.     Active={
  125.         OnBeginState=function(self)
  126.         end,
  127. --        OnUpdate = FlyingFox.OnUpdateActiveServer,
  128.     },
  129. }
  130.  
  131.  
  132. DamageArea.Client={
  133.     OnInit=function(self)
  134.         self:CliSrv_OnInit()
  135.     end,
  136.     OnShutDown=function(self)
  137.     end,
  138.     Inactive={
  139.     
  140.         OnEnterArea = DamageArea.OnEnterAreaClient,
  141.     
  142.     },
  143.     Active={
  144.         OnBeginState=function(self)
  145.  
  146.             self.curDamage = 0,
  147.             self:EnableUpdate(1);
  148.         
  149. --System:Log("Entering INACTIVE");        
  150.         end,
  151.         OnLeaveArea = DamageArea.OnLeaveAreaClient,
  152.         OnProceedFadeArea = DamageArea.OnProceedFadeAreaClient,        
  153. --        OnContact = FlyingFox.OnContactClient,
  154.         OnUpdate = DamageArea.OnUpdateActiveClient,
  155.     },
  156. }
  157.  
  158.  
  159. ----------------------------------------------------------------------------------------------------------------------------
  160. --
  161. function DamageArea:Event_Enable( params )
  162.  
  163.     self.isEnabled = 1;
  164.  
  165. end
  166.  
  167. ----------------------------------------------------------------------------------------------------------------------------
  168. --
  169. function DamageArea:Event_Disable( params )
  170.  
  171.     self.isEnabled = 0;
  172.  
  173. end
  174.  
  175.